import re 


def pc_func(pc_src, func_addr_src):
    with open(func_addr_src, "r") as f:
        func_addr = f.readlines()
    func_addr = [re.split(r" ", i) for i in func_addr]
    func = [i[1] for i in func_addr]
    addr = [eval("0x"+i[0]) for i in func_addr]
    func_addr = dict(zip(addr, func))
    # print(func_addr)

    with open(pc_src, "r") as f:
        pc = f.readlines()
    pc = [eval(i) for i in pc]
    with open("func_call_route.txt", "w") as f:
        for i in pc:
            if i in func_addr:
                f.write(func_addr[i])



def main():
    pc_src = "pc_in_sim.txt"
    func_addr_src = "func_addr.txt"
    pc_func(pc_src, func_addr_src)

main()